﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Text.Editor;
using SandcastleUtils.UI;
using UserControl = System.Windows.Controls.UserControl;

namespace SandcastleUtils.Points
{
    /// <summary>
    /// Interaction logic for UserControl1.xaml
    /// </summary>
    public partial class UserControl1 : UserControl
    {
        private IWpfTextView view;
        private IAdornmentLayer adormentlayer;
        private SVsServiceProvider serviceProvider;
        public int CaretPosition;

        public UserControl1(IWpfTextView wpfTextView, IAdornmentLayer _adornmentLayer, SVsServiceProvider _serviceProvider)
        {
            this.serviceProvider = _serviceProvider;
            view = wpfTextView;
            adormentlayer = _adornmentLayer;
            InitializeComponent();
        }


        public UserControl1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
           // MessageBox.Show("Romla");
            this.view.TextBuffer.Insert(CaretPosition + 1, "Привет из контрола");
            //clear the adornment layer of previous adornments
            adormentlayer.RemoveAllAdornments();
            UpdateLayout();
        }

        private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
        {
          // / TextBlock tb = new TextBlock();
           // Hyperlink link = new Hyperlink();
            //link.NavigateUri = new Uri("C:\\SiteUrls.config");
            
           // Button but = new Button();
           // but.Content = "bug";
           // tb.Inlines.Add(link);



           // grid.Children.Add(but);

            //UpdateLayout();

            //this.view.TextBuffer.Insert(CaretPosition + 1, e.Uri.ToString());
            //adormentlayer.RemoveAllAdornments();
        }

        private void button1_Click_1(object sender, RoutedEventArgs e)
        {
            //System.Windows.Forms.OpenFileDialog openFileDialog = new OpenFileDialog();
            //openFileDialog.ShowDialog();
            String result = "Error";
            addGuiToAmlFile forms = new addGuiToAmlFile(this.serviceProvider);
            forms.ShowDialog();

            this.view.TextBuffer.Insert(CaretPosition + 1, forms.result);

            forms.Dispose();
            adormentlayer.RemoveAllAdornments();
        }
    }
}
